﻿using UnityEngine;
using Proyecto26;
using MrPP.SampleLib;
using System;

namespace Shows_3D
{
    public class ModelLoader : MonoBehaviour
    {
        [SerializeField]
        private string _URL = "http://www.3dshows.cn/app/index.php";
        public string URL
        {
            get
            {
                return _URL;
            }
        }

        void Start()
        {
            RequestHelper options = new RequestHelper();
            options.Uri = _URL;
            options.Params.Add("c", "hololens");
            options.Params.Add("a", "home");

            RestClient.Get<ModelData>(options).Then((data) =>
            {
                if (string.IsNullOrEmpty(data.datas[0].models.md5))
                {
                    data.datas[0].models.md5 = ShowsHelpers.createMD5ByString(data.datas[0].models.url);
                };
                ShowsHelpers.createMD5ByString(data.datas[0].models.url);
                SampleCreater.GetOrCreateInstance.create(data.datas[0].models);
            });
        }
    }
}